const express = require('express');
const router = express.Router();
const multer = require('multer');
const presetFileController = require('../controllers/presetFileController');
const { authenticate, isAdmin } = require('../middlewares/authMiddleware');

// 配置文件上传
const upload = multer({
  dest: 'uploads/temp/',
  limits: {
    fileSize: 10 * 1024 * 1024 // 10MB
  }
});

// 预设文件管理
router.get('/', authenticate, isAdmin, presetFileController.getAllPresetFiles);
router.post('/', authenticate, isAdmin, upload.single('file'), presetFileController.uploadPresetFile);
router.get('/:id', authenticate, isAdmin, presetFileController.getPresetFile);
router.get('/:id/download', authenticate, isAdmin, presetFileController.downloadPresetFile);
router.delete('/:id', authenticate, isAdmin, presetFileController.deletePresetFile);

module.exports = router; 